import hashlib,re
def get_md5(url):
    if isinstance(url,str):
        url=url.encode("utf-8")
    m=hashlib.md5()
    m.update(url)
    return m.hexdigest()

def extract_num(value):
    match_re = re.match(".*?(\d+).*", value)
    if match_re:
        nums = match_re.group(1)
    else:
        nums = 0
    return nums
if __name__=="__main__":
    print(get_md5("http://blog.jobbole.com/all-posts/")) #在py3中所有字符都是UNICODE编码，因此要转换成utf8编码